package com.example.edu.controller;


import com.alibaba.fastjson.JSONObject;
import com.common.util.R;
import com.example.edu.entity.ExportLectures;
import com.example.edu.service.ExportLecturesService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 专家讲座 前端控制器
 * </p>
 *
 * @author lihonghui
 * @since 2023-09-04
 */
@RestController
@RequestMapping("/edu/export-lectures")
@Slf4j
public class ExportLecturesController {

    @Resource
    ExportLecturesService exportLecturesService;

    @PostMapping("insert")
    public R insert(ExportLectures exportLectures) {
        exportLectures.setLectureDetail("专家详情");
        exportLectures.setExportName("专家");
        exportLectures.setLecturePicture("专家图片");
        boolean save = exportLecturesService.save(exportLectures);
        List<ExportLectures> list = exportLecturesService.list();
        log.info("11111===={}", "info");
        log.debug("22222===={}", "debug");
        log.warn("33333===={}", "warn");
        log.error("444444===={}", "error");

        return R.ok().message("新增成功").data(JSONObject.parseObject(JSONObject.toJSONString(exportLectures)));
    }

    @DeleteMapping("del")
    public String delete(Long id) {
        boolean remove = exportLecturesService.removeById(id);
        return "删除成功！！" + remove;

    }
}
